using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;

namespace Common
{
    public class LogHelper
    {
        public static void WriteLogHelper(string message, EventLogEntryType entryType)
        {
            if (!EventLog.SourceExists(CommonConfig.Log))
            {
                EventLog.CreateEventSource(CommonConfig.Log, "Application");
            }
            EventLog.WriteEntry(CommonConfig.Log, message, entryType);
        }

        public static IList<ArraySegment<byte>> CreateData(string str)
        {
            Encoding enc = Encoding.Unicode;

            byte[] array = enc.GetBytes(str);

            ArraySegment<byte>[] segments = new ArraySegment<byte>[1];
            segments[0] = new ArraySegment<byte>(array);

            return Array.AsReadOnly<ArraySegment<byte>>(segments);
        }

        //public static FileRecordSequence GetFileRecordSequence(string path)
        //{
        //    return new FileRecordSequence(path + DateTime.Today.ToShortDateString() + ".log");
        //}
        //public static void Log(IRecordSequence sequence, string str)
        //{
        //    SequenceNumber previous = SequenceNumber.Invalid;
        //    sequence.BeginAppend(CreateData(str), SequenceNumber.Invalid, SequenceNumber.Invalid, RecordAppendOptions.ForceFlush, null, null);
        //}
        
    }
}